

/*
  The following codes need to be run in R to generate the event study Tables A17-A20 in the Appendix

*/
  
  
  
  
*---------------------------------------------------------------------
* Generate Table A17 by running the following code in R.
*---------------------------------------------------------------------
  * so2
rm(list = ls())
library(haven)
Event_sample1 <- read_dta("D:/Nanjing/2019/pollution2/RR2/data/Event_sample_balance.dta")
set.seed(10)
library(did)
out <- att_gt(yname = "lnso2",
              gname = "first_treat",
              idname = "id",
              tname = "year",
              xformla = ~Abatement_so2+Productivity+lnKL+Tariff,
              data = Event_sample1,
              est_method = "reg"
)






summary(out)


ggdid(out)




*--------------------------------------------------------------------
  * Table A18 (dust) in the appendix

rm(list = ls())
library(haven)
Event_sample1 <- read_dta("D:/Nanjing/2019/pollution2/RR2/data/Event_sample_balance.dta")
set.seed(1)
library(did)
out <- att_gt(yname = "lndust",
              gname = "first_treat",
              idname = "id",
              tname = "year",
              xformla = ~Abatement_dust+Productivity+lnKL+Tariff,
              data = Event_sample1,
              est_method = "reg"
)






summary(out)


ggdid(out)




*------------------------------------------------------------------------------------------------
  
  * Table A19: all exporters for so2


rm(list = ls())
library(haven)
Event_sample1 <- read_dta("D:/Nanjing/2019/pollution2/RR2/data/Event_sample_so2_dust.dta")
set.seed(10)
library(did)
out <- att_gt(yname = "lnso2",
              gname = "first_treat",
              idname = "id",
              tname = "year",
              xformla = ~Abatement_so2+Productivity+lnKL+Tariff,
              data = Event_sample1,
              est_method = "reg"
)






summary(out)


ggdid(out)


********************************************************************************************
  *------------------------------------------------------------------------------------------------
  
  * Table 20: all exporters for dust


rm(list = ls())
library(haven)
Event_sample1 <- read_dta("D:/Nanjing/2019/pollution2/RR2/data/Event_sample_so2_dust.dta")
set.seed(10)
library(did)
out <- att_gt(yname = "lndust",
              gname = "first_treat",
              idname = "id",
              tname = "year",
              xformla = ~Abatement_dust+Productivity+lnKL+Tariff,
              data = Event_sample1,
              est_method = "reg"
)






summary(out)


ggdid(out)






